package com.tian.strategy;

import com.tian.enums.PaymentChannelEnum;
import com.tian.factory.ApplicationContextFactory;
import com.tian.service.PaymentService;
import com.tian.service.impl.AliPaymentServiceImpl;
import com.tian.service.impl.WXPaymentServiceImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-11-23 16:59
 * {@code @version:} 1.0
 */
public class PaymentStrategy {

    private static final Map<Integer, PaymentService> PAYMENT_STRATEGY_MAP = new HashMap<>();

    static {
        PAYMENT_STRATEGY_MAP.put(PaymentChannelEnum.ALIPAY.getChannel(), new AliPaymentServiceImpl());
        PAYMENT_STRATEGY_MAP.put(PaymentChannelEnum.WECHAT.getChannel(), new WXPaymentServiceImpl());
    }

    public static PaymentService getPaymentService(Integer channel) {
        return PAYMENT_STRATEGY_MAP.get(channel);
    }
}
